package com.chy.jdbcutil;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.testng.annotations.BeforeClass;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;


public class JDBCUtil {
    protected static Connection conn;
    protected static Statement statement;
    @BeforeClass
    public static void testConnection() throws ClassNotFoundException, IOException, SQLException {
        Class.forName("org.h2.Driver");
         conn=DriverManager.getConnection("jdbc:h2:mem:~/fdStudent");
    }
    @Before
    public static void before() throws SQLException {
        statement = conn.createStatement();
    }
    @After
    public void after() throws SQLException {
        statement.close();
    }
    @AfterClass
    public static void testClose() throws SQLException {
       conn.close();
    }
}
